﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
      <link href="../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../css/Jqbox.css" rel="stylesheet" type="text/css" />
    <link href="../css/jquery.loadmask.css" rel="stylesheet" type="text/css" />
    <script src="../Js/jquery-1.5.2.min.js" type="text/javascript"></script>
    <script src="../Js/ligerui.min.js" type="text/javascript"></script>
    <script src="../Js/jquery.dialog.js" type="text/javascript"></script>
    <script src="../Js/jquery.loadmask.min.js" type="text/javascript"></script>
    <script src="../Js/json2.js" type="text/javascript"></script>
    <script src="../Js/conmon.js" type="text/javascript"></script>
    <script type="text/javascript">
        var Row = null;
        var pWind = null;
        var pFirst = true;
        $(function () {
            $("#form1").ligerForm();
            //$selectRow
            pWind = parent.window.parent.window.getWindow();
            Row = (pWind != null ? pWind.$selectRow : null);


            if (Row != null) {
                $("#txtRole").ligerComboBox({ width: 140, slide: false, data: null });

                //$("#txtRole").ligerGetComboBoxManager().selectValue(0);
                //if (newvalue > 0) {
                    $.getJSON('../WebServer/UserManage.ashx?Action=Department', { areaid: Row.A_ID, Rnd: Math.random() }, function (data) {
                        $("#txtRole").ligerComboBox().setData(data);
                        if (pFirst) {
                            $("#txtRole").ligerComboBox().selectValue(Row.R_ID);
                            pFirst = false;
                        }
                    });
                //}


//                $("#txtArea").ligerComboBox({
//                    width: 140,
//                    selectBoxWidth: 200,
//                    selectBoxHeight: 200, valueField: 'id', treeLeafOnly: false, slide: false, initValue: Row.A_ID,
//                    tree: { url: '../WebServer/MainAdmin.ashx?Action=AreaTree&rnd=' + Math.random(), checkbox: false },
//                    onSelected: function (newvalue) {
//                        
//                    }
//                });

                //赋值
                $("#lbName").text(Row.M_NAME);
                $("#lbSex").text(Row.M_SEX == 0 ? "女" : "男")
                $("#txtCode").val(Row.M_CODE);
                $("#txtTel").val(Row.M_PHONE);
                $("#txtDepartment").val(Row.M_DEPAT);
                $("#txtMail").val(Row.M_EMAIL);

                var proData = [{ id: 0, text: '正常' }, { id: 1, text: '停用'}];

                $("#txtstate").ligerComboBox({ data: proData, isMultiSelect: false }).selectValue(Row.M_STATUS);

            }

            //保存
            $("#btnSave").click(function () {
                if (chk()) {
                    if (Row) {
                        Row.M_CODE = $("#txtCode").val();
                        Row.M_PHONE = $("#txtTel").val();
                        Row.M_DEPAT = $("#txtDepartment").val();
                        Row.M_EMAIL = $("#txtMail").val();
                        //Row.A_NAME = $("#txtArea").val();
                        //Row.A_ID = $("#txtArea_val").val();
                        Row.R_NAME = $("#txtRole").val();
                        Row.R_ID = $("#txtRole_val").val();
                        Row.M_STATUS = $("#txtstate_val").val();
                        Row.M_DATE = "";
                        Row.R_DATE = "";

                        var pars = { data: JSON2.stringify(Row) };
                        $("body").mask("数据处理中，请稍候......");
                        $.post('../WebServer/MainAdmin.ashx?Action=UpdateUser', pars, function (data) {
                            $("body").unmask();
                            var rdata = eval("(" + data + ")");
                            if (rdata.IsSuccess == 1) {
                                showAlertOk("修改成功");
                                if (pWind) pWind.loadGrid();
                            } else {
                                showErrorTip(rdata.Msg);
                            }
                        });
                    } //end row
                } //end chk
            });
            $("#btnCancel").click(function () { closeRefresh(false, ""); });

        });


        function chk() {
            var err = "";

            if ($.trim($("#txtTel").val()) == "")
                err = "请输入手机号码!";

            else if (!chkMoblie($("#txtTel").val())) {
                err = "手机号码输入不正确"
            }
            if (err != "") {
                showErrorTip(err);

                return false;
            }

//            if ($.trim($("#txtArea").val()) == "") {
//                err = "请选择区域!";
//                showErrorTip(err);
//                return false;
//            }
            if ($.trim($("#txtRole").val()) == "") {
                err = "请选择职务!";
                showErrorTip(err);
                return false;
            }

            return true;
        }
      
    </script>

     <style type="text/css">
        .edittable td.editcellmessage,.edittable td.editcellverify,.edittable td.editcell{ padding:5px;line-height:25px;}
        .edittable td.editcellmessage{ padding-left:20px;} 
        body { font-size:12px; background:white;}
         
    </style>
</head>
<body>
<form id="from1" action="">
     <table cellpadding="0" border="0" cellspacing="0" class="edittable">
        <tr>
         <td  class="editcellmessage">用户名:</td>
         <td><label id="lbName"></label></td>
       
         <td  class="editcellmessage">性别:</td>
         <td><label id="lbSex"></label></td>
        </tr>
         <tr>
          <td  class="editcellmessage">工号:</td>
           <td><input id="txtCode" name="txtCode" type="text" ltype="text" /></td>
           <td  class="editcellmessage">电话:</td>
           <td><input id="txtTel" name="txtTel" type="text" ltype="text" /></td>
        </tr>
        <tr>
           <td  class="editcellmessage">工作部门:</td>
           <td><input id="txtDepartment" name="txtDepartment" type="text" ltype="text" /></td>
           <td  class="editcellmessage">Email:</td>
           <td><input id="txtMail" name="txtMail" type="text" ltype="text" /></td>
        </tr>
        <tr>
            <td  class="editcellmessage">职务:</td>
             <td>
             <input id="txtRole" name="txtRole" type="text"  />
              <!--<input id="txtArea" name="txtArea" type="text"  />-->
             </td>
              <td  class="editcellmessage">状态:</td>
             <td>
              <input id="txtstate" name="txtstate" type="text"  />
             </td>
        </tr>
   </table>
       <div class="buttonpanel">
             <div style="float:right;margin-right:10px;">
                 <a id="btnSave" class="button" href="javascript:void(0);"><span>保存</span></a>
                 <a id="btnCancel" class="button" href="javascript:void(0);"><span>关闭</span></a>
              </div>
     </div>
   </form>
</body>
</html>
